package com.sogou.ime.ui.settings.dynamic;

import java.util.ArrayList;

public class KeyboardManager {
	public int currentPageNo = 0;
	public ArrayList<SoftKeyboard> keyboardList = new ArrayList<SoftKeyboard>();
	
	public KeyboardManager()
	{
	}
	
	public boolean addOneKeyboard(SoftKeyboard keyboard)
	{
		keyboardList.add(keyboard);
		
		return true;
	}
	
	public SoftKeyboard getKeyboard(int pageNo)
	{
		if (pageNo <0 || pageNo >= keyboardList.size())
		{
			return new SoftKeyboard();
		}
		
		return keyboardList.get(pageNo);
	}
	
	public boolean setKeyboard(int pageNo, SoftKeyboard keyboard)
	{
		if (pageNo <0 || pageNo >= keyboardList.size())
		{
			return false;
		}
		
		keyboardList.set(pageNo, keyboard);
		
		return true;
	}
	
	public int getKeyboardLayoutCount()
	{
		return keyboardList.size();
	}
	
	public boolean clearKeyboardList()
	{
		keyboardList.clear();
		return true;
	}
	
	public SoftKeyboard getPrevPage()
	{
		if (currentPageNo <=0)
		{
			return keyboardList.get(0);
		}
		
		currentPageNo--;
		return keyboardList.get(currentPageNo);
	}
	
	public SoftKeyboard getNextPage()
	{
		if (currentPageNo >= keyboardList.size() -1 )
		{
			return keyboardList.get(keyboardList.size() -1);
		}
		
		currentPageNo++;
		return keyboardList.get(currentPageNo);
	}
}
